 //index.js
 //获取应用实例
 const app = getApp();
 var common = require("../../public");
 var url = common.url;
 var APP_ID = common.APP_ID;
 var md5 = common.md5Start;
 Page({
     data: {
         zzk: 1,
         bwl: "",
         total_fee: 0.8, //我获得的金额
         open_total_fee: 1.1, //分享者获得金额
         redpack_user_name: '购物战场', //分享者昵称
         help_receive_redbag_alert: false, //帮开红包弹框显示 true：显示    false：不显示
         system_redbag_alert: false, //显示系统红包  true：显示   false：不显示
         battlefield_input_pwd: false, //是否显示 进入战场-输入密码弹框   true：显示   false：不显示
         battlefield_full: false, //是否显示战场参与人数已满  true：显示   false：不显示
         scroll_x: true, //是否可以横向滚动
         noticelist: [], //通知列表数据
         interval: 3000,
         jingxuan_list: [], //精选 数据
         recomment_list: [], //热门推荐数据
         showmask: false, //是否显示 蒙板   true：显示    false：隐藏
         showmask_sign: false, //是否显示签到弹框   true：显示   false：隐藏
         show_sign_alert: false, //是否显示签到弹框 true：显示    false：隐藏
         signArr: [], //签到的数据
         autoplay: true,
         interval: 5000,
         duration: 1000,
         page: 1, //页码热门推荐
         shownewcustom: false, //显示 新手福利 弹框
         bomb_count: 0, //炸弹数量
         bullet_count: 0, //能量块数量
         shield_count: 0, //护盾数量
         score_count: 0, //积分数量
     },
     //领取新手奖励 按钮
     receive_award: function(e) {
         var that = this;
         var session_str = wx.getStorageSync('session_str'); //获取密钥
         //请求领取新手福利接口接口
         wx.request({
             url: url + 'User/newUser',
             data: {
                 session_str: session_str,
                 APP_ID: APP_ID,
                 sign: md5([
                     "session_str" + session_str,
                     "APP_ID" + APP_ID,
                 ])
             },
             header: {},
             method: 'post',
             dataType: 'json',
             responseType: 'text',
             success: function(res) {
                 wx.hideLoading();
                 if (res.data.code == 200) {
                     wx.showToast({
                         title: '领取成功！',
                         icon: 'success',
                         mask: true,
                     })
                     that.setData({
                         showmask: false, //隐藏 蒙板
                         shownewcustom: false, //关闭 新手福利弹框
                     })
                 } else {
                     wx.showToast({
                         title: res.data.msg,
                         icon: 'none',
                         mask: true,
                     })
                 }
             },
             fail: function(res) {
                 wx.hideLoading();
                 wx.showToast({
                     title: '网络错误',
                     icon: 'none',
                     mask: true,
                 })
             }
         });
     },
     //跳转抽奖页面
     go_choujiang: function(e) {
         var session_str = wx.getStorageSync('session_str'); //获取密钥
         if (!session_str) {
             wx.navigateTo({
                 url: '../author/author'
             })
             return false;
         }else{
			 var form_id = e.detail.formId; //formId
			 //加入formid 借口
			 wx.request({
				 url: url + 'User/getFormId',
				 data: {
					 session_str: session_str,
					 form_id: form_id,
					 APP_ID: APP_ID,
					 sign: md5([
						 "session_str" + session_str,
						 "form_id" + form_id,
						 "APP_ID" + APP_ID
					 ])
				 },
				 header: {},
				 method: 'post',
				 dataType: 'json',
				 responseType: 'text',
				 success: function (res) {
				 },
				 fail: function (res) {
				 },
			 })
		 }
         wx.navigateTo({
             url: '../choujiang/choujiang'
         })
     },
     //跳转 购物战场
     pushFormSubmit: function(e) {
         var war_id = e.currentTarget.dataset.warid; //战场id
         var session_str = wx.getStorageSync('session_str'); //获取密钥
         if (!session_str) {
             wx.navigateTo({
                 url: '../author/author'
             })
             return false;
         }
         var form_id = e.detail.formId; //formId
         //加入formid 借口
         wx.request({
             url: url + 'User/getFormId',
             data: {
                 session_str: session_str,
                 form_id: form_id,
                 APP_ID: APP_ID,
                 sign: md5([
                     "session_str" + session_str,
                     "form_id" + form_id,
                     "APP_ID" + APP_ID
                 ])
             },
             header: {},
             method: 'post',
             dataType: 'json',
             responseType: 'text',
             success: function(res) {
             },
             fail: function(res) {
             },
         })
         wx.navigateTo({
             url: '../gouwuzhanchang/gouwuzhanchang?id=' + war_id,
         })
     },
     // 倒计时（热门推荐)
     setCountDown_hot: function() {
         let timer_hot = this.data.timer_hot;
         if (timer_hot) {
             clearTimeout(timer_hot);
         }
         let time = 1000;
         let {
             recomment_list
         } = this.data;
         let list = recomment_list.map((v, i) => {
             if (v.is_start == 1 && v.is_end == 0) {
                 //已开始  正计时
                 if (v.timestamp) {
                     if (v.timestamp <= 0) {
                         v.timestamp = 0;
                         v.countDown = '00:00:00';
                         // return v;
                     }
                     let formatTime = this.getFormat(v.timestamp);
                     v.timestamp += time;
                     v.countDown = `${formatTime.hh}:${formatTime.mm}:${formatTime.ss}`;

                 } else {
                     v.countDown = '00:00:00'; //============做判断   如果没有倒计时的话
                 }
             }
             if (v.is_start == 2 && v.is_end == 0) {
                 //未开始  倒计时
                 if (v.timestamp) {
                     if (v.timestamp <= 0) {
                         v.timestamp = 0;
                         v.countDown = '00:00:00';
                         // return v;
                     }
                     let formatTime = this.getFormat(v.timestamp);
                     v.timestamp -= time;
                     v.countDown = `${formatTime.hh}:${formatTime.mm}:${formatTime.ss}`;

                 } else {
                     v.countDown = '00:00:00'; //============做判断   如果没有倒计时的话
                 }
             }
             return v;

         })
         this.setData({
             recomment_list: list
         });
         timer_hot = setTimeout(this.setCountDown_hot, time);
         this.setData({
             timer_hot: timer_hot
         })
     },
     /**
      * 倒计时(每日精选)
      */
     setCountDown: function() {
         let timer_jingxuan = this.data.timer_jingxuan;
         if (timer_jingxuan) {
             clearTimeout(timer_jingxuan);
         }
         let time = 1000;
         let {
             jingxuan_list
         } = this.data;
         let list = jingxuan_list.map((v, i) => {
             if (v.is_start == 1 && v.is_end == 0) {
                 //已开始  正计时
                 if (v.timestamp) {
                     let formatTime = this.getFormat(v.timestamp);
                     v.timestamp += time;
                     v.countDown = `${formatTime.hh}:${formatTime.mm}:${formatTime.ss}`;

                 } else {
                     v.countDown = '00:00:00'; //============做判断   如果没有倒计时的话
                 }
             }
             if (v.is_start == 2 && v.is_end == 0) {
                 //未开始  倒计时
                 if (v.timestamp) {
                     if (v.timestamp <= 0) {
                         v.timestamp = 0;
                         v.countDown = '00:00:00';
                     }
                     let formatTime = this.getFormat(v.timestamp);
                     v.timestamp -= time;
                     v.countDown = `${formatTime.hh}:${formatTime.mm}:${formatTime.ss}`;

                 } else {
                     v.countDown = '00:00:00'; //============做判断   如果没有倒计时的话
                 }
             }
             return v;

         })
         this.setData({
             jingxuan_list: list,
         });
         timer_jingxuan = setTimeout(this.setCountDown, time);
         this.setData({
             timer_jingxuan: timer_jingxuan
         })
     },

     /**
      * 格式化时间
      */
     getFormat: function(msec) {
         let ss = parseInt(msec / 1000);
         let ms = parseInt(msec % 1000);
         let mm = 0;
         let hh = 0;
         if (ss > 60) {
             mm = parseInt(ss / 60);
             ss = parseInt(ss % 60);
             if (mm > 60) {
                 hh = parseInt(mm / 60);
                 mm = parseInt(mm % 60);
             }
         }
         ss = ss > 9 ? ss : `0${ss}`;
         mm = mm > 9 ? mm : `0${mm}`;
         hh = hh > 9 ? hh : `0${hh}`;
         return {
             ms,
             ss,
             mm,
             hh
         };
     },
     //跳转红包页面
     go_redbag: function(e) {
         var session_str = wx.getStorageSync('session_str'); //获取密钥
         if (!session_str) {
             wx.navigateTo({
                 url: '../author/author',
             })
             return false;
		 } else {
			 var form_id = e.detail.formId; //formId
			 //加入formid 借口
			 wx.request({
				 url: url + 'User/getFormId',
				 data: {
					 session_str: session_str,
					 form_id: form_id,
					 APP_ID: APP_ID,
					 sign: md5([
						 "session_str" + session_str,
						 "form_id" + form_id,
						 "APP_ID" + APP_ID
					 ])
				 },
				 header: {},
				 method: 'post',
				 dataType: 'json',
				 responseType: 'text',
				 success: function (res) {

				 },
				 fail: function (res) {

				 },
			 })
		 }

         wx.navigateTo({
             url: '../redbag/redbag',
         })
     },
     //签到事件
     signin_tap: function(e) {
         var that = this;
         var session_str = wx.getStorageSync('session_str'); //密钥
         if (!session_str) {
             wx.navigateTo({
                 url: '../author/author',
             })
             return false;
		 } else {
			 var form_id = e.detail.formId; //formId
			 //加入formid 借口
			 wx.request({
				 url: url + 'User/getFormId',
				 data: {
					 session_str: session_str,
					 form_id: form_id,
					 APP_ID: APP_ID,
					 sign: md5([
						 "session_str" + session_str,
						 "form_id" + form_id,
						 "APP_ID" + APP_ID
					 ])
				 },
				 header: {},
				 method: 'post',
				 dataType: 'json',
				 responseType: 'text',
				 success: function (res) {

				 },
				 fail: function (res) {

				 },
			 })
		 }
         wx.showLoading({
             title: '加载中',
             mask: true,
         })
         wx.request({
             url: url + 'User/signin',
             data: {
                 session_str: session_str,
                 APP_ID: APP_ID,
                 sign: md5([
                     "session_str" + session_str,
                     "APP_ID" + APP_ID,
                 ])
             },
             header: {},
             method: 'post',
             dataType: 'json',
             responseType: 'text',
             success: function(res) {
                 wx.hideLoading();
                 if (res.data.code == 200) {
                     wx.showToast({
                         title: '签到成功',
                         icon: 'success',
                         mask: true,
                     })
                     that.show_sign_alert();
                 } else {
                     wx.showToast({
                         title: res.data.msg,
                         icon: 'none',
                         mask: true,
                     })
                 }

             },
             fail: function(res) {
                 wx.hideLoading();
                 wx.showToast({
                     title: '网络错误',
                     icon: 'none',
                     mask: true,
                 })
             }
         });
     },
     //显示签到弹框
     show_sign_alert: function(e) {
         var that = this;
         var session_str = wx.getStorageSync('session_str'); //密钥
         if (!session_str) {
             wx.navigateTo({
                 url: '../author/author',
             })
             return false;
		 } else {
			 var form_id = e.detail.formId; //formId
			 //加入formid 借口
			 wx.request({
				 url: url + 'User/getFormId',
				 data: {
					 session_str: session_str,
					 form_id: form_id,
					 APP_ID: APP_ID,
					 sign: md5([
						 "session_str" + session_str,
						 "form_id" + form_id,
						 "APP_ID" + APP_ID
					 ])
				 },
				 header: {},
				 method: 'post',
				 dataType: 'json',
				 responseType: 'text',
				 success: function (res) {

				 },
				 fail: function (res) {

				 },
			 })
		 }
         wx.showLoading({
             title: '加载中',
             mask: true,
         })
         //请求签到详情接口
         wx.request({
             url: url + 'User/signinLog',
             data: {
                 session_str: session_str,
                 APP_ID: APP_ID,
                 sign: md5([
                     "session_str" + session_str,
                     "APP_ID" + APP_ID,
                 ])
             },
             header: {},
             method: 'post',
             dataType: 'json',
             responseType: 'text',
             success: function(res) {
                 wx.hideLoading();
                 if (res.data.code == 200) {
                     that.setData({
                         signArr: res.data.data.list,
                         today_is_signin: res.data.data.today_is_signin, //今日是否签到 true：是
                     })
                     that.setData({
                         showmask: true, //显示蒙板
                         showmask_sign: true, //显示签到弹框
                     })
                 } else {
                     wx.showToast({
                         title: res.data.msg,
                         icon: 'none',
                         mask: true,
                     })
                 }

             },
             fail: function(res) {
                 wx.hideLoading();
                 wx.showToast({
                     title: '网络错误',
                     icon: 'none',
                     mask: true,
                 })
             }
         });

     },
     //关闭签到弹框
     closemask: function(e) {
         this.setData({
             showmask: false, //显示蒙板  true：显示  false：不显示
             showmask_sign: false, //隐藏 签到弹框
             show_sign_alert: false, //显示 签到弹框  true：显示   false：不显示
             battlefield_input_pwd: false, //是否显示 进入战场-输入密码弹框   true：显示   false：不显示
             battlefield_full: false, //是否显示战场参与人数已满  true：显示   false：不显示
             system_redbag_alert: false, //显示系统红包  false：不显示
             shownewcustom: false, //显示 新手福利弹框  true：显示   false：不显示
             help_receive_redbag_alert: false, //帮领红包弹框 true：显示   false：不显示
         })
     },
     //跳转道具页面
     go_daoju: function(e) {
         wx.navigateTo({
             url: '../daoju/daoju'
         })
		 var session_str = wx.getStorageSync('session_str'); //密钥
		 if (session_str){
			 var form_id = e.detail.formId; //formId
			 //加入formid 借口
			 wx.request({
				 url: url + 'User/getFormId',
				 data: {
					 session_str: session_str,
					 form_id: form_id,
					 APP_ID: APP_ID,
					 sign: md5([
						 "session_str" + session_str,
						 "form_id" + form_id,
						 "APP_ID" + APP_ID
					 ])
				 },
				 header: {},
				 method: 'post',
				 dataType: 'json',
				 responseType: 'text',
				 success: function (res) {

				 },
				 fail: function (res) {

				 },
			 })
		 }


     },
     //帮助  跳转 常见问题页面
     go_cjwt: function(e) {
         wx.navigateTo({
             url: '../changjianwenti/changjianwenti'
         })
		 var session_str = wx.getStorageSync('session_str'); //密钥
		 if (session_str) {
			 var form_id = e.detail.formId; //formId
			 //加入formid 借口
			 wx.request({
				 url: url + 'User/getFormId',
				 data: {
					 session_str: session_str,
					 form_id: form_id,
					 APP_ID: APP_ID,
					 sign: md5([
						 "session_str" + session_str,
						 "form_id" + form_id,
						 "APP_ID" + APP_ID
					 ])
				 },
				 header: {},
				 method: 'post',
				 dataType: 'json',
				 responseType: 'text',
				 success: function (res) {

				 },
				 fail: function (res) {

				 },
			 })
		 }
     },
     // 轮播图跳转富文本页面
     go_richText: function(e) {
         var id = e.currentTarget.dataset.id;
         wx.navigateTo({
             url: '../banner_richtext/banner_richtext?id=' + id
         })
     },
     onLoad: function(options) {
         var that = this;
         if (options.shareRedbagid) {
             that.setData({
                 shareRedbagid: options.shareRedbagid
             })
             //   wx.setStorageSync('shareRedbagid', options.shareRedbagid)
         } else {
             that.setData({
                 shareRedbagid: ''
             })
         }
         if (app.globalData.userInfo) {
             this.setData({
                 userInfo: app.globalData.userInfo,
                 hasUserInfo: true
             })
         } else if (this.data.canIUse) {
             // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
             // 所以此处加入 callback 以防止这种情况
             app.userInfoReadyCallback = res => {
                 this.setData({
                     userInfo: res.userInfo,
                     hasUserInfo: true
                 })
             }
         } else {
             // 在没有 open-type=getUserInfo 版本的兼容处理
             wx.getUserInfo({
                 success: res => {
                     app.globalData.userInfo = res.userInfo
                     this.setData({
                         userInfo: res.userInfo,
                         hasUserInfo: true
                     })
                 }
             })
         }
     },
     addXiaoShenTui: function(e) {
         wx.getSetting({
             success: function(res) {
                 if (res.authSetting['scope.userInfo']) {
                     wx.getUserInfo({
                         success: function(res) {
                             var userInfo = res;
                             wx.login({
                                 success: function(res) {
                                     var jsCode = res.code;
                                     app.aldpush.pushuserinfo(userInfo, jsCode);
                                 }
                             })
                         }
                     })
                 }
             }
         })
     },
     onHide: function(e) {},
     onShow: function(e) {
         var that = this;
         this.addXiaoShenTui(); //调用小神推
         var session_str = wx.getStorageSync('session_str'); //获取密钥
         var shareRedbagid = that.data.shareRedbagid; //分享红包id
         if (shareRedbagid) {
             if (!session_str) {
                 wx.navigateTo({
                     url: '../author/author',
                 })
                 return false;
             } else {
                //  console.log('请求帮领红包接口')
                //  console.log('红包id:==', shareRedbagid)


                 //请求帮领红包接口
                 wx.request({
                     url: url + 'Redpack/helpRedpack',
                     data: {
                         session_str: session_str,
                         id: shareRedbagid,
                         APP_ID: APP_ID,
                         sign: md5([
                             "session_str" + session_str,
                             "id" + shareRedbagid,
                             "APP_ID" + APP_ID,
                         ])
                     },
                     header: {},
                     method: 'post',
                     dataType: 'json',
                     responseType: 'text',
                     success: function(res) {
                        //  wx.hideLoading();
                         if (res.data.code == 200) {
                            //  console.log('请求帮领红包接口====成功')
                             that.setData({
                                 help_receive_redbag_alert: true, //显示帮领红包弹框
                                 showmask: true, //显示蒙板
                                 total_fee: res.data.data.total_fee, //我获得的金额
                                 open_total_fee: res.data.data.open_total_fee, //分享者获得金额
                                 redpack_user_name: res.data.data.redpack_user_name, //分享者昵称
                             })
                             that.setData({
                                 shareRedbagid: ''
                             })
                         } else if (res.data.code == 201) {
                            //  console.log('201==', res.data.msg)
                         } else {
                            //  console.log('code=603', res.data.msg)
                         }
                     },
                     fail: function(res) {
                     }
                 });
             }
         } else {

         }
         //请求轮播图接口,请求完成后请求滚动消息接口
         wx.request({
             url: url + 'Banner/bannerlist',
             data: {
                 APP_ID: APP_ID,
                 sign: md5([
                     "APP_ID" + APP_ID,
                 ])
             },
             header: {},
             method: 'post',
             dataType: 'json',
             responseType: 'text',
             success: function(res) {
                //  wx.hideLoading();
                 if (res.data.code == 200) {
                     that.setData({
                         bannerlist: res.data.data
                     })
                 } else {
                     wx.showToast({
                         title: res.data.msg,
                         icon: 'none',
                         mask: true,
                     })
                 }

             },
             fail: function(res) {
                //  wx.hideLoading();
                 wx.showToast({
                     title: '网络错误',
                     icon: 'none',
                     mask: true,
                 })
             },
             complete: function(res) {
                 //   、、请求首页滚动消息接口

                 wx.request({
                     url: url + 'War/getMsg',
                     data: {
                         APP_ID: APP_ID,
                         sign: md5([
                             "APP_ID" + APP_ID,
                         ])
                     },
                     header: {},
                     method: 'post',
                     dataType: 'json',
                     responseType: 'text',
                     success: function(res) {
                        //  wx.hideLoading();
                         if (res.data.code == 200) {
                             that.setData({
                                 noticelist: res.data.data, //滚动消息数据列表
                             })
                         } else {
                             wx.showToast({
                                 title: res.data.msg,
                                 icon: 'none',
                                 mask: true,
                             })
                         }

                     },
                     fail: function(res) {
                         wx.hideLoading();
                         wx.showToast({
                             title: '网络错误',
                             icon: 'none',
                             mask: true,
                         })
                     }
                 });
             }
         });

         //请求发现接口===接口请求完成后  请求 是否有分享（需要帮开）的红包
         wx.request({
             url: url + 'Find/findList',
             data: {
                 APP_ID: APP_ID,
                 sign: md5([
                     "APP_ID" + APP_ID,
                 ])
             },
             header: {},
             method: 'post',
             dataType: 'json',
             responseType: 'text',
             success: function(res) {
                //  wx.hideLoading();
                 if (res.data.code == 200) {
                     var result = res.data.data;
                     var length = result.length;
                     for (let i = 0; i < length; i++) {
                         if (result[i].type == 1) {
                             //如果是红包
                             that.setData({
                                 redbag_title: result[i].name,
                                 redbag_descript: result[i].description,
                                 redbag_type: 1
                             })
                         }
                         if (result[i].type == 2) {
                             //如果是抽奖
                             that.setData({
                                 jifen_title: result[i].name,
                                 jifen_descript: result[i].description,
                                 jifen_type: 2
                             })
                         }
                         if (result[i].type == 3) {
                             //如果是道具活动
                             that.setData({
                                 daoju_title: result[i].name,
                                 daoju_descript: result[i].description,
                                 daoju_type: 3
                             })
                         }
                         if (result[i].type == 4) {
                             //如果是签到
                             that.setData({
                                 sign_title: result[i].name,
                                 sign_descript: result[i].description,
                                 sign_type: 4
                             })
                         }
                         if (result[i].type == 5) {
                             //如果是帮助
                             that.setData({
                                 help_title: result[i].name,
                                 help_descript: result[i].description,
                                 help_type: 5
                             })
                         }
                     }

                 } else {
                     wx.showToast({
                         title: res.data.msg,
                         icon: 'none',
                         mask: true,
                     })
                 }

             },
             fail: function(res) {
                //  wx.hideLoading();
                 wx.showToast({
                     title: '网络错误',
                     icon: 'none',
                     mask: true,
                 })
             },
             complete: function(res) {

             }
         });
         //   、、请求首页每日精选接口
         wx.request({
             url: url + 'War/getFeat',
             data: {
                 APP_ID: APP_ID,
                 sign: md5([
                     "APP_ID" + APP_ID,
                 ])
             },
             header: {},
             method: 'post',
             dataType: 'json',
             responseType: 'text',
             success: function(res) {
                //  wx.hideLoading();
                 if (res.data.code == 200) {
                     var resdata = res.data.data;
                     var now_timstamp = Date.parse(new Date());
                     for (let i = 0; i < resdata.length; i++) {
                         if (resdata[i].start_time * 1000 - now_timstamp > 0) {
                             resdata[i].timestamp = resdata[i].start_time * 1000 - now_timstamp;
                         } else {
                             resdata[i].timestamp = now_timstamp - resdata[i].start_time * 1000;
                         }
                     }
                     that.setData({
                         jingxuan_list: resdata
                     })
                     that.setCountDown();
                 } else {
                     wx.showToast({
                         title: res.data.msg,
                         icon: 'none',
                         mask: true,
                     })
                 }

             },
             fail: function(res) {
                //  wx.hideLoading();
                 wx.showToast({
                     title: '网络错误',
                     icon: 'none',
                     mask: true,
                 })
             }
         });
         //   、、请求首页热门推荐接口
         wx.request({
             url: url + 'War/getHot',
             data: {
                 APP_ID: APP_ID,
                 sign: md5([
                     "APP_ID" + APP_ID,
                 ])
             },
             header: {},
             method: 'post',
             dataType: 'json',
             responseType: 'text',
             success: function(res) {
                //  wx.hideLoading();
                 if (res.data.code == 200) {
                     var resdata = res.data.data;
                     var now_timstamp = Date.parse(new Date());
                     for (let i = 0; i < resdata.length; i++) {
                         if (resdata[i].start_time * 1000 > now_timstamp) {
                             resdata[i].timestamp = resdata[i].start_time * 1000 - now_timstamp;
                         } else {
                             resdata[i].timestamp = now_timstamp - resdata[i].start_time * 1000;
                         }
                     }
					 that.zzkbwl();
                     that.setData({
                         recomment_list: resdata
                     })
                     that.setCountDown_hot();
                 } else {
                     wx.showToast({
                         title: res.data.msg,
                         icon: 'none',
                         mask: true,
                     })
                 }

             },
             fail: function(res) {
                 wx.hideLoading();
                 wx.showToast({
                     title: '网络错误',
                     icon: 'none',
                     mask: true,
                 })
             }
         });

         //请求 是否可以领新手福利的接口
         if (session_str) {
             wx.request({
                 url: url + 'User/isReward',
                 data: {
                     session_str: session_str,
                     APP_ID: APP_ID,
                     sign: md5([
                         "session_str" + session_str,
                         "APP_ID" + APP_ID,
                     ])
                 },
                 header: {},
                 method: 'post',
                 dataType: 'json',
                 responseType: 'text',
                 success: function(res) {
                    //  wx.hideLoading();
                     if (res.data.code == 200) {
                         that.setData({
                             showmask: true, //是否显示 蒙板   true：显示    false：隐藏
                             shownewcustom: true, //显示 新手福利 弹框
                             bomb_count: res.data.data.bomb_count, //炸弹数量
                             bullet_count: res.data.data.bullet_count, //能量块数量
                             shield_count: res.data.data.shield_count, //护盾数量
                             score_count: res.data.data.score_count, //积分数量
                         })
                     } else {

                     }
                 },
                 fail: function(res) {
                 }
             });
         }




		 },
		 zzkbwl:function(){
			//  var zzk = this.data.zzk;
			//  if (zzk == 2) {
			// 	 var bwl = this.data.bwl
			// 	 wx.showToast({
			// 		 title: bwl,
			// 		 icon: 'none',
			// 		 duration: 2000,
			// 	 });
			// 	 this.setData({
			// 		 zzk: 1,
			// 		 bwl: ""
			// 	 })

			//  }
		 },
     /**
      * 页面上拉触底事件的处理函数
      */
     onReachBottom: function() {
         var that = this;
         var page = this.data.page; //热门推荐 页码
         var recomment_list = this.data.recomment_list; //热门推荐数据
         page++;
         wx.showLoading({
             title: '加载中',
             mask: true,
         })
         //   、、请求首页热门推荐接口
         wx.request({
             url: url + 'War/getHot',
             data: {
                 APP_ID: APP_ID,
                 page: page,
                 sign: md5([
                     "APP_ID" + APP_ID,
                     "page" + page,
                 ])
             },
             header: {},
             method: 'post',
             dataType: 'json',
             responseType: 'text',
             success: function(res) {
                 wx.hideLoading();
                 if (res.data.code == 200) {
                     var resdata = res.data.data;
                     if (resdata.length == 0) {
                         wx.showToast({
                             title: '没有更多数据',
                             icon: 'none',
                             mask: true,
                         })
                     }
                     var now_timstamp = Date.parse(new Date());
                     for (let i = 0; i < resdata.length; i++) {
                         if (resdata[i].start_time * 1000 > now_timstamp) {
                             resdata[i].timestamp = resdata[i].start_time * 1000 - now_timstamp;
                         } else {
                             resdata[i].timestamp = now_timstamp - resdata[i].start_time * 1000;
                         }
                     }
                     recomment_list = recomment_list.concat(resdata)
                     that.setData({
                         recomment_list: recomment_list,
                         page: page
                     })
                     that.setCountDown_hot();
                 } else {
                     wx.showToast({
                         title: res.data.msg,
                         icon: 'none',
                         mask: true,
                     })
                 }

             },
             fail: function(res) {
                 wx.hideLoading();
                 wx.showToast({
                     title: '网络错误',
                     icon: 'none',
                     mask: true,
                 })
             }
         });
     },

     /**
      * 用户点击右上角分享
      */
     onShareAppMessage: function() {

     }
 })
